// 对账单

import { FileListType } from '@renderer/types/global'
import axios from 'axios'
const modelUrl = '/finance'
// 应收应付账款
export interface AccountsReq {
  billId?: string
  supplierId?: string
  customerId?: string
  curReceivableAmt: number
  curReceivableExclTaxAmt: number
  historyUnreceiveAmt: number
  curReceivedAmt: number
  writeAmt: number
  remainReceivableAmt: number
  sellers: string
  billDesc: string
  billType: number
  remark: string
  detailList: AccountsResItemDetailList[]
  fileList?: FileListType[]
  billTime: string[]
  billStartDate: string
  billEndDate: string
  sellersId?: string
  historyUnreceiveExclTaxAmt: number
  curReceivedExclTaxAmt: number
  remainReceivableExclTaxAmt: number
}
export interface AccountsRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: AccountsResItem[]
}
export interface AccountsResItemDetailList {
  relatedOrderId: string
  relatedOrderCode: string
  deliveryDate?: string
  amt: number
}
export interface AccountsResItem {
  purchaseNum: number
  billId: string
  customerName?: string
  supplierName?: string
  customerId: string
  curReceivableAmt: number
  publicAccountAmt?: number
  privateAccountAmt?: number
  curReceivableExclTaxAmt: number
  historyUnreceiveAmt: number
  curReceivedAmt: number
  writeAmt: number
  remainReceivableAmt: number
  sellers: string
  billDesc: string
  billType: number
  remark: string
  detailList: AccountsResItemDetailList[]
  batchCount: number
  createdDt: string
  index?: number // 导出的序号
  fileList?: FileListType[]
  billTime: string[]
  billStartDate: string
  billEndDate: string
  historyUnreceiveExclTaxAmt: number
  curReceivedExclTaxAmt: number
  remainReceivableExclTaxAmt: number
}
export interface AccountsListSearch {
  sellers?: string
  supplierName?: string
  customerName?: string
  createdStartDate?: string
  createdEndDate?: string
  billType?: number
  createTime?: string[]
  billTime?: string[]
  billStartDate?: string
  billEndDate?: string
}

export interface BatchAddType {
  billType: number
  billEndDate: string
  sellersId?: string
}

export interface billHistoryUnreceiveAmtType {
  billType: number
  supplierId?: string
  customerId?: string
  billStartDate: string
  billEndDate: string
}

export function editAccounts(data: AccountsReq) {
  return axios.post<AccountsRes>(modelUrl + '/billAdit', data)
}

export function delAccounts(data: { billId: string }) {
  return axios.post<object>(modelUrl + '/billDel', data)
}

export function getAccountsDetail(data: { billId: string }) {
  return axios.post<AccountsResItem>(modelUrl + '/billDetail', data)
}

export function getAccountsAllList(data?: AccountsListSearch) {
  return axios.post<AccountsRes>(modelUrl + '/billList', data)
}

export function getAccountsPageList(data: AccountsListSearch) {
  return axios.post<AccountsRes>(modelUrl + '/billPage', data)
}

export function batchAddAccounts(data: BatchAddType) {
  return axios.post<AccountsRes>(modelUrl + '/billAddBatch', data)
}

export function getBillHistoryUnreceiveAmt(data: billHistoryUnreceiveAmtType) {
  return axios.post<AccountsResItem>(modelUrl + '/billHistoryUnreceiveAmt', data)
}
// 应付账款
// export interface AccountsPayableReq {
//   customerId?: string
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
// }
// export interface AccountsPayableRes {
//   currentPage?: number
//   pageSize?: number
//   totalPage?: number
//   totalCount?: number
//   list: AccountsPayableResItem[]
// }
// export interface AccountsPayableResItem {
//   customerId: string
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
//   createdDt: string
//   createdBy: string
//   updatedBy: string
//   updatedDt: string
//   detailList: []
// }
// export interface AccountsPayableListSearch {
//   customerName?: string
//   taxNo?: string
//   contactName?: string
//   createTime: string[]
// }

// export function editAccountsPayable(data: AccountsPayableReq) {
//   return axios.post<AccountsPayableRes>(modelUrl + '/erpAccountsPayableAdit', data)
// }

// export function delAccountsPayable(data: { customerId: string }) {
//   return axios.post<object>(modelUrl + '/erpAccountsPayableDel', data)
// }

// export function getAccountsPayableDetail(data: { customerId: string }) {
//   return axios.post<AccountsPayableResItem>(modelUrl + '/erpAccountsPayableDetail', data)
// }

// export function getAccountsPayableAllList(data?: AccountsPayableListSearch) {
//   return axios.post<AccountsPayableRes>(modelUrl + '/erpAccountsPayableList', data)
// }

// export function getAccountsPayablePageList(data: AccountsPayableListSearch) {
//   return axios.post<AccountsPayableRes>(modelUrl + '/erpAccountsPayablePage', data)
// }
